package com.villaday.idf.adapter2;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.model2.Districts;
import com.villaday.idf.model2.ShippingAddressesEntity;
import com.villaday.idf.util.PhoneUtil;

/**
 * Created by tudou on 2018/10/8.
 */

public class AddrAdapter extends AbsRecyclerViewAdapter<ShippingAddressesEntity.BodyEntity> {
    private View.OnClickListener onClickListener;

    public AddrAdapter(Context context, View.OnClickListener onClickListener) {
        super(context, R.layout.item_addr);
        this.onClickListener = onClickListener;
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, ShippingAddressesEntity.BodyEntity d, int position) {
        holder.bindTextView(R.id.tv_name, d.getLinkman())
                .bindTextView(R.id.tv_phone, d.getOverlayMobile())
                .bindTextView(R.id.tv_addr, d.getRegion() + d.getAddress())
                .setViewVisible(R.id.tv_moren, d.isPreferred() ? View.VISIBLE : View.GONE);
        View view = holder.getView(R.id.img_edit);
        view.setTag(position);
        view.setOnClickListener(onClickListener);

        PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_phone),true);

    }
}
